<?php

$alphabet = @$_GET['alphabet'];
$listfilter = "";
$listfilter = @$_GET['listfilter'];
$WhereFilter = "";
$listfilter_htmlcode = $PACTS_cfg->remove_duplicated_amps("listfilter=".$listfilter."&amp;");

if ($alphabet==null or $alphabet == ""){
    $alphabet="all";
}
$alphabet_htmlcode = 'alphabet='.$alphabet.'';


$FamilyId = @$_GET['FamilyId'];
$IndividualId = $_GET['IndividualId'];

$WhereFilter = $PACTS_cfg->getListHeader($listfilter_htmlcode,$alphabet,"Indv_az_list.php","Indv_allentries.php","Individuals",$listfilter,'IndividualId='.$IndividualId.'&amp;FamilyId='.$FamilyId);

$link = 'Indv_az_list.php?'.$alphabet_htmlcode.'&amp;';

//echo FilterList($listfilter,$link,&$WhereFilter);
$WhereFilter = 'TRUE '.$WhereFilter;

$submitData = @$_POST['submitData'];
$PHPSESSID = @$_GET['PHPSESSID'];
$SubmitDeleteIndividualPhoto = @$_POST['SubmitDeleteIndividualPhoto'];



if($PACTS_cfg->getUserCanModify()) {
    if($submitData == "Update information" or $SubmitDeleteIndividualPhoto=="Delete Photo")
    {
        $PACTS_cfg->PMA_gpc_extract($HTTP_POST_VARS, $GLOBALS);
    }


    if (strlen($IndividualId) > 0) {

        $sql = "SELECT *, ".$PACTS_cfg->individualtablename.".CommentText as IndvCommentText FROM ((($PACTS_cfg->individualtablename INNER JOIN $PACTS_cfg->familytablename ON $PACTS_cfg->individualtablename.FamilyId = $PACTS_cfg->familytablename.FamilyId) LEFT JOIN $PACTS_cfg->gendertablename ON $PACTS_cfg->individualtablename.GenderCode = $PACTS_cfg->gendertablename.GenderCode) LEFT  JOIN $PACTS_cfg->titletablename ON $PACTS_cfg->individualtablename.Title = $PACTS_cfg->titletablename.Title) LEFT  JOIN $PACTS_cfg->roletypetablename ON $PACTS_cfg->individualtablename.RoleTypeCode = $PACTS_cfg->roletypetablename.RoleTypeCode WHERE $PACTS_cfg->individualtablename.IndividualId=$IndividualId;";
        $result = mysql_query($sql ,$PACTS_cfg->dblink);
        $resultsnumber = mysql_num_rows($result);
        //	echo "&nbsp;<b>Number of entries: $resultsnumber</b><br />";
        $links = mysql_fetch_assoc($result);

        $FirstName = $links["FirstName"];
        $Surname = $links["Surname"];
        $Title = $PACTS_cfg->getLookValue($PACTS_cfg->titletablename, "Title", $links["Title"], "Description");
        $Gender = $PACTS_cfg->getLookValue( $PACTS_cfg->gendertablename,"GenderCode", $links["GenderCode"], "Description");
        $role = $links["RoleTypeCode"];

        echo '<p />'."\n";
        echo '<div id="details-section">'."\n";
        echo '<div id="viewHeading">'."\n";
        echo $PACTS_cfg->getIndvNavBar($IndividualId, $FamilyId."&amp;".$listfilter_htmlcode.$alphabet_htmlcode, TRUE, FALSE, TRUE, "Fmly_view","",TRUE,'<a class="nbt" href="index.php?view=Fmly_view&amp;'.$listfilter_htmlcode.$alphabet_htmlcode.'&amp;'.'FamilyId='.$FamilyId.'">View&nbsp;Fmly</a>',FALSE);

        ////////////////////////////////

        echo '<p class="IndvName">'.trim("$Title $FirstName $Surname").':</p>'."\n";
        echo '<p class="IndvRole">'.$Gender.' '.$role.'</p>'."\n";
    }

    echo '</div>'."\n";
    ?>


<p class="titlename1">Edit Individual</p>
<?php
//		echo "<pre>";
//		print_r($_POST);
//		echo "</pre>";

if($submitData == "Update information" or $SubmitDeleteIndividualPhoto=="Delete Photo")
{
    $PACTS_cfg->PMA_gpc_extract($HTTP_POST_VARS, $GLOBALS);
    $IndividualId = $fields['IndividualId'];
    $FamilyId = $fields['FamilyId'];

    $fields_changes = array();
    $fields_changes_prev = array();
    $fields_invalid = array();
    $fields_changes_SQL = array();

    // check fields for validity
    $bInvalidField = FALSE;

    foreach ($fields as $fields_key => $fields_value) {
        if($fields_prev[$fields_key] == $fields_value) {
        }
        else
        {
            if(is_array($fields_value)) {
                // must be a date
                // put date back together and check validity
                //					echo "<pre>";
                //					print_r($fields_value);
                //					echo "fields_value['DayOfMonth'] = ".$fields_value['DayOfMonth']." ".strlen($fields_value['DayOfMonth'])."\n";
                //					echo "fields_value['Month'] = ".$fields_value['Month']." ".strlen($fields_value['Month'])."\n";
                if (strlen($fields_value['Month'])==0){ $fields_value['Month']="January";}
                if (strlen($fields_value['DayOfMonth'])==0){ $fields_value['DayOfMonth']="1";}

                //					echo "fields_value['Year'] = ".$fields_value['Year']." ".strlen($fields_value['Year']);
                //					echo "</pre>";


                $mon = $PACTS_cfg->getNumMonthFromString($fields_value['Month']);
                $day = $PACTS_cfg->getNumDayOfMonthFromString($fields_value['DayOfMonth']);
                $year = $fields_value['Year'];

                //						echo "<b> $fields_key Date : $day ".$fields_value['Month']." $year</b><p>";

                if( is_numeric($day) && is_numeric($mon) && is_numeric($year) && checkdate( $mon, $day, $year ) ) {
                    //	valid
                }
                else{
                    // invalid
                    echo "<br /><b>Invalid $fields_key : $day ".$fields_value['Month']." $year</b><br />";
                    $bInvalidField = TRUE;
                    $fields_changes[$fields_key] = FALSE;
                }

                $compileDate=$day."-".$mon."-".$year;
                if($year=="") {
                    $compileDate = "blank";
                }
                $fields_changes[$fields_key] = $compileDate;



                $fields_changes_SQL[$fields_key] = $year."-".$mon."-".$day;
                // $PACTS_cfg->get prev date
                $mon = $PACTS_cfg->getNumMonthFromString($fields_prev[$fields_key]['Month']);
                $day = $fields_prev[$fields_key]['DayOfMonth'];
                $year = $fields_prev[$fields_key]['Year'];
                $compileDate=$day."-".$mon."-".$year;
                if($day=="" and ($mon=="" or $mon==0) and $year=="") {
                    $compileDate = "blank";
                }
                $fields_changes_prev[$fields_key] = $compileDate;

            }else
            {
                if($fields_key == "IndividualPhoto") {
                    //					echo "photo : ".$fields_value."<p>";
                    //					echo "photo_type : ".$fields[$fields_key."_size"]."<p>";
                    //					echo "photo_size : ".$fields_value."<p>";
                } else{
                    $fields_changes_SQL[$fields_key] = $fields_value;
                    $fields_changes[$fields_key] = $fields_value;
                    $fields_changes_prev[$fields_key] = $fields_prev[$fields_key];
                }
            }
        }
    }

    // do photo
    if (@$_FILES['IndividualPhoto']['name']) {
        $contents = mysql_escape_string(fread(fopen($_FILES['IndividualPhoto']['tmp_name'],"r"), filesize($_FILES['IndividualPhoto']['tmp_name'])));
        $fields_changes_SQL['IndividualPhoto'] = $contents;
        $fields_changes['IndividualPhoto'] = $contents;
        array_push ($fields_changes_prev, "IndividualPhoto" );
    }

    // build SQL for operation
    $updateSql = "UPDATE Individual SET ModificationTMS = now(), ModificationUserId = '".$_SESSION['username']."'";
    if(count($fields_changes)>0) {
        echo "<hr>";
        foreach ($fields_changes as $fields_key => $fields_value) {

            if($fields_key == "IndividualPhoto") {
                $hexvalue = $contents;
                $updateSql .= ", IndividualPhoto = '".$contents."' ";
                $updateSql .= ", IndividualPhotoName = '".$_FILES['IndividualPhoto']['name']."' ";
                $updateSql .= ", IndividualPhotoSize = '".$_FILES['IndividualPhoto']['size']."' ";
                $updateSql .= ", IndividualPhotoType = '".$_FILES['IndividualPhoto']['type']."' ";
                echo '<p class="changes">\''.$fields_key.'\' to be updated</p><br />'."\n";
                $PACTS_cfg->InsertAuditTrailEntry("", $_FILES['IndividualPhoto']['name']." (".$_FILES['IndividualPhoto']['size']." bytes , ".$_FILES['IndividualPhoto']['type'].")" , "Edit", "Individual", "IndividualPhoto" ,$_SESSION['username'],$_SERVER['PHP_SELF'],$IndividualId);



            } else{

                if(!strlen($fields_value)>0) {
                    $updateSql .= ", $fields_key = NULL ";
                } else {
                    $updateSql .= ", $fields_key = '".$fields_changes_SQL[$fields_key]."' ";
                }



                $PACTS_cfg->InsertAuditTrailEntry($fields_changes_prev[$fields_key], $fields_value ,"Edit","Individual",$fields_key,$_SESSION['username'],$_SERVER['PHP_SELF'],$IndividualId);

                echo '<p class="changes">\''.$fields_key.'\' changed from ';
                echo $fields_changes_prev[$fields_key].'\' ---> ';
                echo '\''.$fields_value.'\' </p><br />'."\n";
            }
            echo "<hr>";
        }
        $updateSql .= " WHERE IndividualId = $IndividualId;";
        //			echo "$updateSql<p>";

        $result_update = mysql_query($updateSql,$PACTS_cfg->dblink);
    }
    else
    {
        if($SubmitDeleteIndividualPhoto!="Delete Photo")  {
            echo '<hr>'."\n";
            echo '<p class="changes">no changes!</p><br />'."\n";
            echo '<hr>'."\n";
        }
    }
}


if($SubmitDeleteIndividualPhoto=="Delete Photo") {
    // delete stored photo
    $updateSql = "UPDATE Individual SET ModificationTMS = now(), ModificationUserId = '".$_SESSION['username']."'";
    $updateSql .= ", IndividualPhoto = '' ";
    $updateSql .= ", IndividualPhotoName = '' ";
    $updateSql .= ", IndividualPhotoSize = '' ";
    $updateSql .= ", IndividualPhotoType = '' ";
    $updateSql .= " WHERE IndividualId = $IndividualId;";
    $result_update = mysql_query($updateSql,$PACTS_cfg->dblink);
    $PACTS_cfg->InsertAuditTrailEntry("IndividualPhoto", "" ,"Edit","Individual","IndividualPhoto",$_SESSION['username'], $_SERVER['PHP_SELF'],$FamilyId);
    echo '<hr>'."\n";
    echo '<p class="changes">Photo deleted</p><br />'."\n";
    echo '<hr>'."\n";
}


if($IndividualId > 0)
{
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    $oTableCol = new TableColumn("Individual",$PACTS_cfg->aMySQLType);


    $sql =  "SELECT * FROM Individual WHERE IndividualId=$IndividualId;";
    $result = mysql_query($sql,$PACTS_cfg->dblink);
    $resultsnumber_Indv = mysql_num_rows($result);
    $myrow = mysql_fetch_array($result);

    // gather column information
    $sql_cols = "SHOW COLUMNS FROM Individual;";
    $result_cols = mysql_query($sql_cols);
    $Indv_ColumnInfo = mysql_fetch_array($result_cols);

    $URLmessage="Individual details updated!";
    $mycount=0;
    echo "\n";
    echo '<form method="post" enctype="multipart/form-data" action="'.$HTTP_SERVER_VARS['PHP_SELF'].'?view=Indv_edit&amp;IndividualId='.$IndividualId.'&amp;FamilyId='.$FamilyId.'&amp;URLmessage='.$URLmessage.'&amp;PHPSESSID='.$PHPSESSID.'">'."\n";
    echo '<div id="viewDetailsC2">'."\n";
    echo '<input type="hidden" name="fields[IndividualId]" value="'.$IndividualId.'" />'."\n";
    echo '<input type="hidden" name="fields_prev[IndividualId]" value="'.$IndividualId.'" />'."\n";
    echo '<input type="hidden" name="fields[FamilyId]" value="'.$FamilyId.'" />'."\n";
    echo '<input type="hidden" name="fields_prev[FamilyId]" value="'.$FamilyId.'" />'."\n";


    while ($Indv_ColumnInfo = mysql_fetch_array($result_cols)) {
        $mycount++;
        $Field = $Indv_ColumnInfo["Field"];
        $Value = $myrow[$Field];
        $DayOfMonth = "";
        $Month = "";
        $Year = "";
        $Ychecked = "";
        $Nchecked = "";
        $inputOptions = "";
        // conditions for different fields on screen
        // e.g. Readonly for ModificationTMS and ModificationUserId
        $bREADONLY = FALSE;
        $bHIDDEN = FALSE;

        // if field ends with UserId or TMS then READONLY
        // if field ends with IndividualId then HIDDEN

        if(strtoupper( substr($Field, strlen($Field)-6,6)) == "USERID") {
            $bREADONLY = FALSE;
            $inputOptions = $PACTS_cfg->inputREADONLY  ;
        }


        if(strtoupper( substr($Field, strlen($Field)-3,3)) == "TMS") {
            $bREADONLY = FALSE;
            $inputOptions = $PACTS_cfg->inputREADONLY  ;
        }

        $strCheckFor = "PHOTOTYPE";
        if(strtoupper( substr($Field, strlen($Field)-strlen($strCheckFor),strlen($strCheckFor))) == $strCheckFor) {
            $bHIDDEN = TRUE;
        }

        $strCheckFor = "PHOTOSIZE";
        if(strtoupper( substr($Field, strlen($Field)-strlen($strCheckFor),strlen($strCheckFor))) == $strCheckFor) {
            $bHIDDEN = TRUE;
        }
        $strCheckFor = "PHOTONAME";
        if(strtoupper( substr($Field, strlen($Field)-strlen($strCheckFor),strlen($strCheckFor))) == $strCheckFor) {
            $bHIDDEN = TRUE;
        }

        if(!$bHIDDEN) {echo "<ul>\n"; }

        list ($CType, $CSize) = $oTableCol->getTypeSize($Field);
        if(!$bHIDDEN) {echo "  ";}
        $fieldDescription = trim($PACTS_cfg->getFieldDescription("Individual", $Field));
        if(!strlen($fieldDescription)>0 and !$bHIDDEN)  {
            $fieldDescription = "No description available";
        }

        if(!$bHIDDEN) {
            echo '<li class="viewDetailsHeader" title="'.$fieldDescription.'" >'.$Field;

            if($Field=="WorkTypeCode") {
                echo '&nbsp;<a href="Help/ANZSIC.php" rel="external" class="pagetext">(HELP)</a>'."\n";
            }

            echo '</li>'."\n";
            echo '<li class="viewDetailsDataEdit">'."\n";
        }


        if(@$PACTS_cfg->aFieldLookUpTableList[$Field] and !$bHIDDEN) {
            echo '<!-- start aFieldLookUpTableList -->'."\n";

            echo "".$PACTS_cfg->getLookupTableHTML($Field,"fields[".$Field."]",$Value,$mycount );
            echo '</li>'."\n";
            echo '<li class="viewDetailsLookup">'."\n";

            //					echo "<table border=0 cellspacing=0 cellpadding=0>\n<tr>";
            //					echo "<td class=\"txtbot\">";
            //					echo "</td>";
            if (strstr($Field, "Title")) {
                $iposA = strpos($Field, "Title");
                //						echo "<td rowspan=2 class=\"txtbot\">&nbsp;qqqqq";
                $strPreFix = substr($Field, 0, $iposA);
                echo $PACTS_cfg->getSelectListOfCommonlyUsedNameTitles($Field,"",$mycount,"</td><td rowspan=2>&nbsp;"  );
            }
            //					echo "</tr><tr class=\"lookuprow\"><td class=\"txtbot\">";
/*
            if (strtoupper($PACTS_cfg->aFieldLookUpTableList[$Field]['Description']) != "DESCRIPTION")
            {
                echo '<p class="FieldDescriptionText">'."\n";
                echo "(".$PACTS_cfg->aFieldLookUpTableList[$Field]['Description']."";
                if($Field=="FamilyID") {
                    echo ", Head of Family";

                }

                if(@strlen($PACTS_cfg->aFieldLookUpTableList[$Field]['Description2'])>0) {
                    echo ", ".@$PACTS_cfg->aFieldLookUpTableList[$Field]['Description2']."";
                }
                echo ")</p><br />";
            }
*/
            echo "\n";
            echo '<input type="hidden" name="fields_prev['.$Field.']" value="'.$Value.'" />';

            //					echo "</td></tr></table>\n";
            //					echo "</td>\n";
            echo '<!-- end aFieldLookUpTableList -->'."\n";
        }else
        {
            switch (TRUE) {
                case ($PACTS_cfg->aMySQLType[trim($CType)]==$PACTS_cfg->textbox AND $CSize<$PACTS_cfg->intMaxInputBoxSize and !$bHIDDEN):
                    //
                    // TEXTBOX
                    //

                    echo "\n\n";
                    echo '<input type="hidden" name="fields_prev['.$Field.']" value="'.$Value.'" />';

                    echo '<input type="text" name="fields['.$Field.']" value="'.$Value.'" size="'.$CSize.'" maxlength="'.$CSize.'" class="'.$PACTS_cfg->textbox.'"';
                    if (strstr($Field, "KindergartenCommenceYear")) {
                        echo ' id="KCY" ';
                    }
                    echo $inputOptions.'/>';
                    break;


                case ($PACTS_cfg->aMySQLType[trim($CType)]==$PACTS_cfg->textareabox OR ($PACTS_cfg->textbox AND $CSize>=$PACTS_cfg->intMaxInputBoxSize )and !$bHIDDEN) :
                    //
                    // TEXTAREABOX
                    //
                    if(is_null($CSize) or $CSize=="") {
                        $CSize = $PACTS_cfg->intTextAreaDefaultCharCount;
                    }
                    if($Field == "CommentText") {
                        $CSize = $PACTS_cfg->intTextAreaDefaultCharCount;
                    }

                    // if size is over 50 then use textarea
                    // <textarea name="address" rows="5" cols="35"></textarea>
                    echo "\n\n";
                    echo '<input type="hidden" name="fields_prev['.$Field.']" value="'.$Value.'" />';
                    echo "\n\n";
                    echo '<textarea name="fields['.$Field.']" rows="'.((int)($CSize/$PACTS_cfg->intTextAreaColSize)+1).'" cols="'.$PACTS_cfg->intTextAreaColSize .'" '.$inputOptions.'>'.$Value.'</textarea>';
                    break;

                case ($PACTS_cfg->aMySQLType[trim($CType)]==$PACTS_cfg->enumcheckbox and !$bHIDDEN):
                    echo "\n\n";
                    if($Value=='Y') {
                        $Ychecked = ' checked="checked" ';
                    }else
                    {
                        $Nchecked = ' checked="checked" ';
                    }
                    echo '<input type="hidden" name="fields_prev['.$Field.']" value="'.$Value.'" />';
                    echo "\n";
                    echo '<input type="radio" name="fields['.$Field.']" value="Y"'.$Ychecked .' /><label>Y</label>';
                    echo "\n";
                    echo '<input type="radio" name="fields['.$Field.']" value="N"'.$Nchecked .' /><label>N</label>';
                    break;
                case ($PACTS_cfg->aMySQLType[trim($CType)]==$PACTS_cfg->imagebox and !$bHIDDEN):
                    echo '<table border="0">';
                    echo "<tr>";
                    echo '<td align="center">'."\n";
                    if(strlen($Value)==0) {
                        echo '&nbsp;';
                    }else{
                        echo '<a href="index.php?view=display_image_full&amp;IndividualId='.$IndividualId.'" >'."\n";
                        echo '<img src="index.php?view=display_image_thumb&amp;IndividualId='.$IndividualId.'&amp;height=70" alt="" />'."\n";
                        echo '</a>'."\n";
                    }
                    echo '</td><td align="center">'."\n";
                    echo "Click browse to update image";

                    if(strlen($Value)>0) {
                        echo "<p class=\"smalltxt\"><input type=\"checkbox\" id=\"deleteIndividualPhoto\" name=\"SubmitDeleteIndividualPhoto\" value=\"Delete Photo\" class=\"smalltxt\" title=\"Delete Photo\" />&nbsp;Delete Photo</p>\n";
                    }
                    echo "</td></tr>"."\n";
                    echo "<tr><td>"."\n";
                    echo "";

                    if(strlen($Value)==0) {
                        echo '<p class="smalltxt">No image!</p>'."\n";
                    }else{
                        echo '<p class="smalltxt">'.(int)(strlen($Value)/1024).'Kb Image File</p>'."\n";
                    }
                    echo "</td><td>"."\n";
                    echo '<input type="hidden" name="MAX_FILE_SIZE" value="1000000000" />'."\n";
                    echo '<input type="file" name="IndividualPhoto" accept="image/gif,image/jpeg,image/png" /><br />'."\n";
                    echo '<input type="hidden" name="fields_prev[\'IndividualPhoto\']" value="" /><br />'."\n";
                    echo "</td>"."\n";
                    echo "</tr>"."\n";
                    echo "</table>"."\n";
                    break;
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case ($PACTS_cfg->aMySQLType[trim($CType)]==$PACTS_cfg->timebox and !$bHIDDEN):

                    $tmp1 = $PACTS_cfg->myts_date("H:i:s - l jS F y",$Value);
                    //$tmp1 = date("YmdHis"); //YYYYMMDDHHMMSS
                    print "$tmp1";
                    break;
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case ($PACTS_cfg->aMySQLType[trim($CType)]==$PACTS_cfg->timedatebox and !$bHIDDEN):
                    print "[timedate]";
                    break;
                case ($PACTS_cfg->aMySQLType[trim($CType)]==$PACTS_cfg->yearbox and !$bHIDDEN):
                    print "[year]";
                    break;
                case ($PACTS_cfg->aMySQLType[trim($CType)]== $PACTS_cfg->datebox and !$bHIDDEN):
                    // 'YYYY-MM-DD' format

                    $mydate = $PACTS_cfg->myts_date("d-F-Y",$Value,0,5,8);
                    $DayOfMonth = $PACTS_cfg->myts_date("d",$Value,0,5,8);
                    $Month = $PACTS_cfg->myts_date("F",$Value,0,5,8);
                    $Year = $PACTS_cfg->myts_date("Y",$Value,0,5,8);

                    echo '<table class="DateEditTable">'."\n";
                    echo '<tr class="dateheadings">'."\n";
                    echo '<td>Day</td>'."\n";
                    echo '<td>Month</td>'."\n";
                    echo '<td>Year</td>'."\n";
                    echo '</tr>'."\n";
                    echo '<tr>'."\n";




                    echo '<td>'.$PACTS_cfg->getDayOfMonthHTML('fields['.$Field.'][DayOfMonth]',$DayOfMonth).'</td>'."\n";
                    echo '<td>'.$PACTS_cfg->getMonthHTML('fields['.$Field.'][Month]',$Month).'</td>'."\n";
                    echo '<td><input type="text" name="fields['.$Field.'][Year]" value="'.$Year.'" size="4" maxlength="4" class="'.$PACTS_cfg->datebox.'" />'."\n";

                    echo '<input type="hidden" name="fields_prev['.$Field.'][DayOfMonth]" value="'.$DayOfMonth.'"/>'."\n";
                    echo '<input type="hidden" name="fields_prev['.$Field.'][Month]" value="'.$Month.'"/>'."\n";
                    echo '<input type="hidden" name="fields_prev['.$Field.'][Year]" value="'.$Year.'"/>'."\n";

                    echo '</td>'."\n";
                    echo '</tr>'."\n";
                    echo '</table>'."\n";
                    break;
            } // end switch

            if (strstr($Field, "KindergartenCommenceYear")) {
                //					' find string up to Suburb
                $iposA = strpos($Field, "Suburb");
                $strPreFix = substr($Field, 0, $iposA);
                echo '</li>'."\n";
                echo '<li class="viewDetailsLookup">'."\n";
                echo $PACTS_cfg->getSchoolYearOption($Field,$strPreFix,"" );
            }
            //echo '</td>'."\n";
        }// end else
        if(!$bHIDDEN) {
            echo '</li>'."\n";
            echo '</ul>'."\n";;
        }
    }
    echo '<ul><li class="viewDetailsHeader"></li>'."\n";
    echo '<li class="viewDetailsDataEdit">'."\n";

    echo '<input type="submit" class="smalltxtInput" name="submitData" value="Update information" />';
    echo '</li></ul>'."\n";
    echo '<!-- end DIV viewDetailsC1 -->'."\n";
    echo '</div>'."\n";

    echo '</form>'."\n";
    echo '</div>'."\n";
    //				echo '</td><tr></table>'."\n";
}
}
else {
   echo '<div id="details-section">'."\n";
    echo '<div id="viewDetailsC2">'."\n";

    echo '<p class="errmsg1">Error! You do not have permission to modify data!</p>'."\n";
    echo '</div>'."\n";
    echo '</div>'."\n";
}



?>